import unittest
from BSTestRunner import BSTestRunner
import time

if __name__ == '__main__':
    # 批量加载测试用例
    test_dir = r'../test_case'
    discover = unittest.defaultTestLoader.discover(test_dir, pattern='test*.py')

    # 拼装测试报告文件名
    report_dir = r'../reports'
    now = time.strftime('%Y-%m-%d %H_%M_%S')
    report_name = rf'{report_dir}\{now}report.html'

    # 执行并生成测试报告
    with open(report_name, mode='wb') as f:
        runner = BSTestRunner(f, title='测试报告', description='测试详情')
        runner.run(discover)
